#include <iostream>

#include "XM_Logger.hh"
#include "XM_Timestamp.hh"

XM_Logger& XM_Logger::instance()
{
    static XM_Logger logger;

    return logger;
}

void XM_Logger::setLogLevel(int level)
{
    logLevel__ = level;
}

void XM_Logger::log(std::string msg)
{
    std::string pre{""}; // need std c++ 20
    switch (logLevel__)
    {
    case INFO:
        pre = "[INFO]";
        break;
    case ERROR:
        pre = "[ERROR]";
        break;
    case FATAL:
        pre = "[FATAL]";
        break;
    case DEBUG:
        pre = "[DEBUG]";
        break;
    default:
        break;
    }

    std::cout << pre + XM_Timestamp::now().toString() << " : " << msg << std::endl;
}